package cn.kgm.autoCancel.quartz;

import java.util.Arrays;
import java.util.List;
import java.util.concurrent.DelayQueue;
import java.util.concurrent.TimeUnit;

/**
 * @Version 1.8
 * @Author: Kappi
 * @Date: 2023-9-15 11:20
 * @Description: cn.kgm.autoCancel.quartz.DelayActuatorHandle
 */
public class DelayActuatorHandle {

    public static void main(String[] args) {
        List<String> list = Arrays.asList("nihao", "wohao", "jiutabuhao");

        DelayQueue<DelayActuator> queue = new DelayQueue<>();

        for (int i = 0; i < list.size(); i++) {
            queue.put(new DelayActuator(list.get(i), TimeUnit.NANOSECONDS.convert(3, TimeUnit.SECONDS)));
            try {
                queue.take().print();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
}
